<!DOCTYPE html>
<html lang="en">

<!--
  Author：蓝田_Loto
  Date：2018-11-09 18:36
  PageName：c_attribute_checkValidity.html
  Function：显式验证 - checkValidity()方法
  URL：http://localhost:8080/j_form/j6_form_attribute/c_attribute_checkValidity.html
-->

<head>
    <meta charset="UTF-8">
    <title>显式验证 - checkValidity()方法</title>

    <script>
        function check() {
            var email = document.getElementById("email");
            if (email.value == "") {
                alert("请输入Email地址");
                return false;
            }
            else if (!email.checkValidity()) {
                alert("请输入正确的Email地址");
                return false;
            }
            else
                alert("您输入的Email地址有效");
        }
    </script>
</head>

<body>
<form id=testform onsubmit="return check();" novalidate>
    <label for=email>Email</label>
    <input name=email id=email type=email/><br/>
    <input type=submit>
</form>
</body>
</html>